// 公司设置相关接口
import request from '@/utils/request'

/**
 * @description 根据id查询企业
 * @param {String} id 公司id
 * @returns Promise
 */
export const getCompanyInfo = (id) => {
  return request({
    url: `/company/${id}`,
    method: 'GET'
  })
}

/**
 * @description 获取所有角色列表
 * @returns Promise
 */
export const getAllRoles = (page, pagesize) => {
  return request({
    url: '/sys/role',
    method: 'GET',
    params: {
      page,
      pagesize
    }
  })
}

/**
 * @description 添加角色
 * @param {*} data
 * @returns Promise
 */
export const addNewRole = (data) => {
  return request({
    url: '/sys/role',
    method: 'POST',
    data
  })
}

/**
 * @description 根据ID更新角色
 * @param {*} id
 * @param {*} data
 * @returns Promise
 */
export const alterRoleById = (id, data) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'PUT',
    data
  })
}

/**
 * @description 根据ID获取角色详情
 * @param {*} id
 * @returns Promise
 */
export const getRoledetailById = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'GET'
  })
}

/**
 * @description 根据ID删除角色
 * @param {*} id
 * @returns Promise
 */
export const removeRoleById = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'DELETE'
  })
}

/**
 * @description 获取所有权限点
 * @returns Promise
 */
export const getAllpermissions = () => {
  return request({
    url: '/sys/permission',
    method: 'GET'
  })
}

/**
 * @description 给角色分配权限
 * @param {*} id 角色id
 * @param {*} permIds 权限
 * @returns Promise
 */
export const assignPremAPI = (id, permIds) => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'PUT',
    data: {
      id,
      permIds
    }
  })
}
